package com.tm.mholmu.activity;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import com.example.mholmu.R;
import com.tm.mholmu.application.Util;
import com.tm.mholmu.db.DBUtils;
import com.tm.mholmu.db.Outfit;
import com.tm.mholmu.db.Outfits;
import com.tm.mholmu.db.SkillBaseAdapter;

public class MainActivity extends Activity {
	TextView t;
	EditText et;
	ListView lv;
	SkillBaseAdapter sa;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	//	t = (TextView) findViewById(R.id.cs);
		et = (EditText) findViewById(R.id.e1);
		lv = (ListView) findViewById(R.id.l1);
	}

	public void name1(View v) {
		
		// DBUtils.getInstance().getDBService().AddAllSkill(Util.intiskill());
		// List<Outfit> o = Util.intidata();

		/*StringBuffer sb = new StringBuffer();
		//List<Skill> sk = Util.intiskill();

		for (int i = 0; i < 10; i++) {
			sb.append("名称是" + o.get(i).name+" 类型是"+o.get(i).distance+" 部位是"+o.get(i).part+" 孔数是"
					+o.get(i).hole+" 技能是"+o.get(i).skill+" 名称代号和值是"+o.get(i).N_1+"*"+o.get(i).Z_1
					);
			sb.append("\n");
		}
		t.setText(sb);*/
		// List<Skill> sk = Util.intiskill();
		/*
		for (int i = 0; i <sk.size(); i++) {
			sb.append("id2是"+sk.get(i).id2+"  名称是"+sk.get(i).name+"  值是"+sk.get(i).point+"  内容是"+sk.get(i).comment);
			sb.append("\n");
		}
		*/
	}

	public Outfits getou(List<Outfit> lo) {
		Outfits o = new Outfits(lo.get(0), lo.get(1), lo.get(2), lo.get(3), lo.get(4), new Outfit());
		
		return o;
	}
	public void name2(View v) {
		List<Outfit> lo=DBUtils.getInstance().getDBService().getOutfit(52, "近");
		sa= new SkillBaseAdapter(getou(lo), MainActivity.this);
		
		lv.setAdapter(sa);
		
		/*
		StringBuffer sb = new StringBuffer();
		int d = Integer.valueOf(et.getText().toString().equals("") ? "10" : et
				.getText().toString());

		List<Outfit> o = DBUtils.getInstance().getDBService().getOutfit(d, "近");
		sb.append("结果是:" + o.size());
		for (int i = 0; i < o.size(); i++) {
			sb.append("名称是" + o.get(i).name + " 类型是" + o.get(i).distance
					+ " 部位是" + o.get(i).part + " 孔数是" + o.get(i).hole + " 技能是"
					+ o.get(i).skill + " 名称代号和值是" + o.get(i).N_1 + "*"
					+ o.get(i).Z_1);
			sb.append("\n");
		}
		t.setText(sb);

		*/}
}
